<!DOCTYPE html>
<html lang="en">
<head>
        <meta charset="UTF-8">
        <title>综合</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.1.0.js"></script>
</head>
<body>
<table border="1" align="center">
    <tr>
        <th>订单号</th>
        <td><input id='orderNumber' type='text' ></td>
    </tr>
    <tr>
        <th>支付金额</th>
        <td><input id='amount' type='number' value=0.01></td>
    </tr>
    <tr>
        <th>用户Id</th>
        <td><input id='userId' type='number' value=1></td>
    </tr>
    <tr>
        <th>标题</th>
        <td><input id='title' type='text'value="测试"></td>
    </tr>
    <tr>
        <th>描述</th>
        <td><input id='description' type='text' value="支付测试"></td>
    </tr>
</table>
<div align="center">
    <button type="button" onclick="wechat() ">微信支付</button>
    <button type="button" onclick="union()">银联支付</button>
    <button type="button"  ><a href="query.html" style="text-decoration:none;">支付订单查询</a></button>
    <button type="button"  ><a href="fileup.html" style="text-decoration:none;">shanhch</a></button>
    <button type="button" align="center"  ><a href="newdown.html" style="text-decoration:none;">种子下载(你懂的)</a></button>

</div>
</body>

<script>
            var host = "http://prdear.imwork.net:17406";
//            var host = "http://localhost:8080";
    function wechat() {
        var JSONObject1 = {
            "orderNumber": $("#orderNumber").val()
            , "amount": $("#amount").val()
            , "userId": $("#userId").val()
            , "title": $("#title").val()
            , "description": $("#description").val()
        };
        $.ajax({
            type: "POST",
//            url: location.protocol + '//' + location.host + "/user/item/1",
            url:host+"/wechat/pay",
            data: JSONObject1,
            dataType: "json",
            success: function (data) {
                if ( data.code === '201' ){
                    var  result = data.data;
                    $("body").html("<img src='data:image/jpeg;base64," + result + "'/>");
                }else{
                    alert(data.data);
                }
            },

        });
    }
    function union() {
        var JSONObject2 = {
            "orderNumber": $("#orderNumber").val()
            , "amount": $("#amount").val()
            , "userId": $("#userId").val()
            , "title": $("#title").val()
            , "description": $("#description").val()
        };
        $.ajax({
            type: "POST",
//            url: location.protocol + '//' + location.host + "/user/item/1",
            url:host+"/unionpay/pay",
            data: JSONObject2,
            dataType: "json",
            success: function (data) {
                if ( data.code === '201' ){
                    var  result = data.data.data;
                    $("body").html(result);
                }else{
                    alert(data.data);
                }
            }
        });
    }
</script>

</html>